/**
 * 系统设置 电子病例
 */
<template>

<el-row :gutter="20">
  <el-col :span="8">
    <div class="grid-content bg-purple">
      <div class="block" >
        <el-timeline>
          <el-timeline-item v-for="(item,index) in listData" :key="item.id" :timestamp="item.date" placement="top">
            <div @click="getDetail(index,item.id)">
              <el-card  >
                <span>患者姓名:&nbsp;&nbsp;{{item.name}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                <span>门诊编号:&nbsp;&nbsp;{{item.id}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                <span>诊断:{{item.diagnosis}}</span>
                <br/>
                <span>接诊科室:&nbsp;&nbsp;{{item.office}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                <span>医生:&nbsp;&nbsp;{{item.doctorName}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
              </el-card>
            </div>
          </el-timeline-item>
        </el-timeline>
      </div>
    </div>
  </el-col>

  <el-col :span="16">
    <div class="grid-content bg-purple-light">

    <el-button @click="workbenchPage()" class="backButton" type="primary">返回到工作台主页</el-button>
    
    <h3>体格信息</h3>
    体温：{{detailData.bodyTemperature}}℃   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   呼吸：{{detailData.breathe}}次/分&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 脉搏：{{detailData.pulse}}次/分 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;血压：{{detailData.bloodPressure}}mmHg
    <br/>
    血糖：{{detailData.bloodGlucose}} mmol/L &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 血脂：{{detailData.bloodFat}} mmol/L &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 身高：{{detailData.height}}cm  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 体重：{{detailData.weight}}kg
    
    <h3>处方信息</h3>
      <p>处方类型：{{prescriptionData.prescriptionType}}</p>
      <div v-for="(item,index) in prescriptionData.prescriptionItemList" :key="item.id">
      <p>{{index+1}}.{{item.commonName}}</p> 
      <span>药品总数量：{{item.quantity}} {{item.unit}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
      <span>用法：{{item.usage}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
      <span>单次用量：{{item.dosage}}{{item.dosageUnit}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
      <span>用药频率：{{item.frequency}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
      <span>用药持续时间：{{item.medicineDays}}天</span>
      </div>

    <h3>病例信息</h3>
      <p>发病日期：{{detailData.accidentDate}}</P>
      <p>主诉：{{detailData.symptom}}</P>
      <p>现病史：{{detailData.presentIllnessHistory}}</P>
      <p>既往史：{{detailData.anamnesis}}</P>
      <p>过敏史：{{detailData.allergy}}</P>
      <p>个人史：{{detailData.personalHistory}}</P>
      <p>家族史：{{detailData.familyHistory}}</P>
      <p>辅助检查：{{detailData.examination}}</P>
      <p>初步诊断：{{detailData.diagnosis}}</P>
      <p>治疗意见：{{detailData.cure}}</P>
      <p>医嘱：{{detailData.doctorAdvice}}</P>
      <p>备注：{{detailData.remark}}</P>

    </div>
  </el-col>
</el-row>

</template>

<script>
// 导入组件
import axios from 'axios'
export default {
  data() {
    return {
      listData: [],
      detailData: {},
      prescriptionData:{}

      }
  },
  // 注册组件
  components: {
  },
  /**
   * 创建完毕获取列表
   */
  created() {
    this.getdata();




  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    // 获取列表
    getdata() {
      console.log("传过来的值是:",this.$route.query);
      axios.post('/api/register/selectCase',{patientId:this.$route.query.patientId,pageNum:1,pageSize:999})
        .then(res => {
          console.log('结果是',res)     
          this.listData = res.data.data.list

          this.getDetail(0,this.listData[0].id)

        })
        .catch(err => {
          this.$message.error('病例列表加载失败，请稍后再试！')
        })

        
    },
    getDetail(index,prescriptionKey){
      this.detailData=this.listData[index];
      console.log("详细数据是---",this.detailData)

      axios.get('/api/prescription/selectAll/'+prescriptionKey+'/1/999')
        .then(res => {
          console.log('结果是',res)     
          this.prescriptionData = res.data.data.list[0]
          console.log('处方信息',this.prescriptionData)

        })
        .catch(err => {
          this.$message.error('病例列表加载失败，请稍后再试！')
        })

    },
        // 跳转至患者信息页面
    workbenchPage(){
      this.$router.push({
        path:"/workbench/workbench",
        query:{
          
          }
      })
    }   
  }
}
</script>

<style scoped>
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;

  }

  .p{
    font-size: 10px;
  }
  .span{
    font-size: 10px;
  }
  .backButton{
    float:right;
  }

</style>

 
 